package com.duan.order.listener;

import com.alibaba.fastjson.JSONObject;
import com.duan.order.config.RabbitMqConfig;
import com.duan.order.service.OrderService;
import com.duan.order.service.TaskService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class listener {

    @Autowired
    private TaskService taskService;
    @Autowired
    private OrderService orderService;

    @RabbitListener(queues = RabbitMqConfig.TASK_QUEUE)
    public void task(Long taskId){
        taskService.delete(String.valueOf(taskId));
    }

    @RabbitListener(queues = RabbitMqConfig.ERROR_QUEUE)
    public void orderFail(Long orderId){
        orderService.delete(String.valueOf(orderId));
    }
}
